<script>
import { getAlertGoods } from '@/api/goods'

export default {
  name: 'alert',
  data() {
    return {
      list: []
    }
  },
  methods: {
    getData() {
      getAlertGoods().then(res => {
        this.list = res.data
      })
    }
  },
  mounted() {
    this.getData()
  }
}
</script>

<template>
  <div class="alert-wrapper">
    <div class="page-header">库存报警</div>
    <div class="goods-list">
      <div class="good-item" v-for="item in list" :key="item.spbh">
        <div class="good-name">{{ item.spname }}</div>
        <div class="kc">库存：{{ item.kc || 0 }}</div>
        <div class="kc">库存下限：{{ item.downkc }}</div>
        <div class="jj">进价： {{item.newjj}}</div>
      </div>
      <div class="empty" v-if="!list.length">暂时没有报警商品库存</div>
    </div>
  </div>
</template>

<style scoped lang="scss">
.alert-wrapper {
  padding: 20px;
  .page-header {
    display: flex;
    align-items: center;
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 20px;
    &:before {
      content: '';
      display: inline-block;
      width: 4px;
      height: 20px;
      border-radius: 4px;
      background-color: #0075ff;
      margin-right: 10px;
    }
  }

  .goods-list {
    .good-item {
      border: 1px solid #cecece;
      padding: 8px 10px;
      font-size: 0.8rem;
      border-radius: 8px;
      margin-bottom: 10px;
      box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.1);
      .good-name {
        font-size: 1rem;
        font-weight: bold;
        margin-bottom: 8px;
      }
    }
    .empty {
      text-align: center;
      color: #666666;
    }
  }
}
</style>
